package com.java.text;

import java.util.Scanner;

public class TestEX5 {
	public static void main(String[] args) {

		test01();
	}

	private static void test01() {
		try {
			// 引入分苹果的算数异常
			int appleNum = 0;
			int stuNum = 0;

			System.out.println("************现在给孩子们发苹果************");

			Scanner sc = new Scanner(System.in);

			System.out.println("请输入苹果数：");
			appleNum = sc.nextInt();
			System.out.println("请输入孩子数：");
			stuNum = sc.nextInt();

			System.out.println("每个孩子分到的苹果数为：" + (appleNum / stuNum));
			System.out.println("孩子们现在非常开心！");

			// 引入老师的算法异常
			String teachers[] = { "小明", "张三", "李四" };
			for (int i = 0; i <= teachers.length; i++) {
				System.out.println(teachers[i]);
			}
		} catch (ArrayIndexOutOfBoundsException e) {
			// 捕获数组下标越界
			System.out.println("数组下标越界，请修改下标！");
		} catch (ArithmeticException e) {
			// 捕获算数异常
			System.out.println("算数异常，请修改算数!");
		}

	}
}
